<template>
  <div class="page">
    <div class="top_div">
      <div class="in_div flex_ac" @click="$back() ">
        <van-icon class="ml6" name="arrow-left" size="26" color="#000"/>
        <div class="nav_title">链商</div>
      </div>
      <div class="main">
        <div class="t_n ml20 mb6">成武重点产业链</div>
        <div class="t_n1 ml20 mb16">纵览产业全链，挖掘客户，洞察商机</div>
        <div class="input_div flex_ac">
          <img width="20px" height="20px" class="mr10 ml15" src="~@/assets/img/search.png" alt="">
          <input type="text" placeholder="输入产业词、产品，例如“生物医药’" v-model="keywords">
        </div>
        <div class="flex_ac">
          <div class="sss mr15">热搜</div>
          <div class="chain_sss" v-for="i,k in list.slice(0,2)" :key="k">{{ i.chain_name }}</div>
        </div>
      </div>
    </div>
    <div class="bbb flex_sb flex_w">
      <div class="chain_item" v-for="i,k in list" :key="k" @click="toDetail(i.id)">
        <img :src="i.chain_img" alt="">
        <div class="name">{{ i.chain_name }}</div>
        <div class="name1">{{ i.company_num }}家企业</div>
      </div>
    </div>
  </div>
</template>
<script>
import { GetChainLevelList } from '@/api/api.js'
export default {
  data() {
    return {
      page: 1,
      total: 0,
      isfinish: false,
      isLoad: true,
      list: [],
      keywords:'',
    }
  },
  components: {
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.page = 1
      this.isfinish = false
      this.isLoad = true
      this.list = []
      this.getList()
    },
    getMore() {
      if (this.isfinish||this.list.length==0) {
        return
      }
      this.page++
      this.getList()
    },
    getList() {
      this.$toast.loading({
        message: '加载中...',
        forbidClick: true,
      });
      GetChainLevelList({
        page:1,
        company_num_fag: 1,
        city_id:2380,
        keywords:this.keywords,
        chain_num_fag: 1,
      }).then(res => {
        this.isLoad = false
        this.list.push(...res.data.data)
        this.total = res.data.total
        if (this.list.length >= this.total) {
          this.isfinish = true
        }
        this.$toast.clear()
      })
    },
    toDetail(id) {
      this.$router.push({
        name: 'chainDetail',
        query: {
          id
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.page{
  height: auto;
  overflow: hidden;
}
.top_div{
  position: relative;
  width: 100%;
  background: #FAE6CC;
  height: 220px;
  .in_div{
    position: absolute;
    left: 0;
    top: 10px;
    z-index: 10;
    color: #000;
  }
  .title{
    position: absolute;
    left: 10px;
    top: 10px;
    font-weight: 500;
		font-size: 18px;
		color: #000;
  }
  .main{
    position: absolute;
    width: 100%;
    left: 0px;
    top: 60px;
    .t_n{
      font-weight: bold;
      font-size: 22px;
      color: #000000;
    }
    .t_n1{
      font-size: 13px;
      color: #000000;
    }
  }
  .input_div{
    height: 40px;
    margin: 10px;
    border-radius: 8px;
    border: 1px solid #999999;
    background: #fff;
    overflow: hidden;
    input{
      border: none;
      font-size: 14px;
      width: calc(100% - 40px);
      height: calc(100% - 4px);
    }
  }
}

.sss{
  font-weight: 600;
  font-size: 14px;
  color: #000000;
  margin-left: 20px;
  line-height: 14px;
}
.chain_sss{
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  background: #FDF4EC;
  border-radius: 2px;
  font-size: 11px;
  color: #FA8A26;
  margin-right: 15px;
}
.bbb{
  width: 100%;
  background: #fff;
  border-radius: 5px;
  position: relative;
  top: -5px;
  padding: 10px;
  box-sizing: border-box;
}
.chain_item{
  width: 170px;
  height: 95px;
  background: rgba(0,0,0,0.6);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-bottom: 15px;
  &::after{
    content: ' ';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #0008;
    z-index: 10;
  }
  img{
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: block;
  }
  .name{
    position: absolute;
    z-index: 20;
    width: 100%;
    text-align: center;
    top: 20px;
    font-size: 18px;
    color: #FFFFFF;
  }
  .name1{
    position: absolute;
    bottom: 20px;
    left: calc(50% - 40px);
    z-index: 20;
    line-height: 20px;
    text-align: center;
    width: 80px;
    height: 20px;
    background: rgba(255,255,255,0.5);
    border-radius: 10px;
    font-size: 13px;
    color: #FFFFFF;
  }
}
</style>